<!DOCTYPE html>
<html lang="zh" xmlns:th="http://www.thymeleaf.org" >
<head>
    <th:block th:include="include :: header('新增项目')" />

<!--    <th:block th:include="include :: summernote-css" />-->
</head>
<body class="white-bg">
    <div class="wrapper wrapper-content animated fadeInRight ibox-content">
        <form class="form-horizontal m" id="form-project-add">
            <div class="form-group">    
                <label class="col-sm-3 control-label is-required">项目名称：</label>
                <div class="col-sm-8">
                    <input id="name" name="name" class="form-control"  placeholder="项目名称不能超过20个字" type="text" th:required="true" >
                </div>
            </div>

                <div class="form-group">
                    <label class="col-sm-3 control-label is-required">负责人：</label>
                    <div class="col-sm-8">
                        <div class='input-group'>
                            <input class='form-control' type='hidden' name="empId" id='empId' required>
                            <input class='form-control' type='text'  id='userAuditName' readonly="readonly" required>
                            <span class='input-group-addon input-sm' onclick='selectDictTree("", this)'>
                            <i class='fa fa-search'>选择</i>
                        </span>
                        </div>
                    </div>

                </div>

            <div class="form-group">
                <label class="col-sm-3 control-label is-required">迭代状态：</label>
                <div class="col-sm-8">
                    <select name="status" th:with="type=${@dict.getType('sys_project_status')}" class="form-control m-b">
<!--                        <option value="">所有</option>-->
                        <option th:each="dict : ${type}" th:text="${dict.dictLabel}" th:value="${dict.dictValue}"></option>
                    </select>
                </div>
            </div>

            <div class="form-group">
                <label class="col-sm-3 control-label">描述：</label>
                <div class="col-sm-8">
                    <div>
                    <textarea  name="contentDescribe" id="contentDescribe"  class="form-control" placeholder="给项目写点描述"></textarea>
                    </div>
                </div>
            </div>


        </form>
    </div>
    <th:block th:include="include :: footer" />

    <th:block th:include="include :: summernote-js" />
    <script type="text/javascript">
        var prefix = ctx + "project/project"
        $("#form-project-add").validate({
            focusCleanup: true
        });

        function submitHandler() {
            if ($.validate.form()) {
                $.operate.save(prefix + "/add", $('#form-project-add').serialize());
            }
        }

        $("#name").keyup(function(){
            var str = $("#name").val();
            if (str.length > 20 ){
                $("#name").val(str.substring(0,20));
                 $.modal.alertWarning("字数限制在20字以内");
            }
        });

        $("#contentDescribe").keyup(function(){
            var str = $("#contentDescribe").val();
            if (str.length > 100 ){
                $("#contentDescribe").val(str.substring(0,100));
                $.modal.alertWarning("字数限制在100字以内");
            }
        });


        function selectDictTree(columnId, obj) {
            var url = ctx + "system/user/selectUserTree";
            var options = {
                title: '选择审核人',
                width: "380",
                url: url,
                callBack: doSubmit
            };
            $.modal.openOptions(options);
        }

        function doSubmit(index, layero){
            var body = layer.getChildFrame('body', index);
            var userId = body.find('#userId').val();
            var userNameShow = body.find('#userNameShow').val();
            layer.close(index);
            $("#empId").val(userId);
            $("#userAuditName").val(userNameShow);
            // document.getElementById("userName").value=userName;
        }
    </script>
</body>
</html>